package com.kl.forum.service;

import com.kl.forum.dao.UserHealthyMapper;
import com.kl.forum.entity.UserHealthy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class UserHealthyService {
    @Autowired
    private UserHealthyMapper userHealthyMapper;

    public int addUserHealthy(Integer userId,Integer healthyId){
        UserHealthy userHealthy=new UserHealthy();
        userHealthy.setUserId(userId);
        userHealthy.setHealthyId(healthyId);
        userHealthy.setCreateTime(new Date());
        return userHealthyMapper.insertSelective(userHealthy);
    }
    public  UserHealthy findUserHealthyBy(Integer userId, Integer healthyId){
        Map map=new HashMap();
        map.put("userId",userId);
        map.put("healthyId",healthyId);
        map.put("status",1);
        return userHealthyMapper.findUserHealthyBy(map);
    }
    public int update(UserHealthy userHealthy){
        return  userHealthyMapper.updateByPrimaryKeySelective(userHealthy);
    }
}
